package com.jnevision.leavefeeset.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.jnevision.leavefeeset.model.LeaveFeeSet;
import com.jnevision.leavefeeset.service.LeaveFeeSetServiceImpl;

/**
 * <p>
 * 请假费用设置 前端控制器
 * </p>
 *
 * @author gavin
 * @since 2019-07-26
 */

@RestController
@RequestMapping("/leavefeesets")
public class LeaveFeeSetController extends ApiController {
    @Autowired
    public LeaveFeeSetServiceImpl leaveFeeSetServiceImpl;

    @PostMapping
    public R<Boolean> add(@RequestBody LeaveFeeSet feeset) {
        return this.success(this.leaveFeeSetServiceImpl.saveOrUpdate(feeset));
    }

    @GetMapping
    public R<LeaveFeeSet> get(int deptId) {
        return this.success(this.leaveFeeSetServiceImpl.getOne(new QueryWrapper<LeaveFeeSet>().eq("dept_id", deptId)));
    }
}
